<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="80px">
      <el-form-item label="商品编码" prop="id">
        <el-input
          v-model="queryParams.id"
          placeholder="请输入商品编码"
          clearable
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="素材编码" prop="imgId">
        <el-input
          v-model="queryParams.imgId"
          placeholder="请输入素材编码"
          clearable
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="店铺" prop="shopId">
        <el-select v-model="queryParams.shopId" filterable clearable @keyup.enter.native="handleQuery" style="width: 240px" placeholder="请选择店铺">
          <el-option
            v-for="item in storeMgmtList"
            :key="item.id"
            :label="item.storeAbbr"
            :value="item.id">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="商品ID" prop="productId">
        <el-input
          v-model="queryParams.productId"
          placeholder="请输入商品ID"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="印刷品" prop="printedMaterials">
        <el-select v-model="queryParams.printedMaterials" clearable @keyup.enter.native="handleQuery" style="width: 240px" placeholder="请选择是否印刷品">
          <el-option
            v-for="item in [{ label: '是', value: 'Y' }, { label: '否', value: 'N' }]"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="上传时间" prop="createTime">
        <el-date-picker
          v-model="dateRange"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          @keyup.enter.native="handleQuery"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="材质名称" prop="imgMaterial">
        <el-select v-model="queryParams.imgMaterial" filterable clearable placeholder="请选择材质"  @keyup.enter.native="handleQuery">
          <el-option v-for="item in matMgmtList" :key="item.id" :label="item.matName" :value="item.id" />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8" ref="toolbar">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          @click="handleAdd"
          v-hasPermi="['business:prodRel:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['business:prodRel:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['business:prodRel:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="info"
          plain
          icon="el-icon-upload2"
          @click="handleImport"
          v-hasPermi="['business:prodRel:import']"
        >导入</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="info"
          plain
          icon="el-icon-refresh"
          @click="handleRefreshCache"
          v-hasPermi="['business:prodRel:refreshCache']"
        >刷新缓存</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
    <div :style="'height:' + divHeight + 'px'">
      <el-table ref="divTable" v-loading="loading" :data="prodRelList" @selection-change="handleSelectionChange" @expand-change="handleExpandChange">
        <el-table-column type="expand">
          <template v-slot="scope">
            <el-table ref="details" :data="scope.row.children" :height="scope.row.height" v-loading="detailsLoading">
              <el-table-column label="素材编码" prop="imgId" align="center" />
              <el-table-column label="预览图" prop="imgPngPath" align="center">
                <template v-slot="scope">
                  <image-preview :src="getImageUrl(scope.row.bucketUrl, scope.row.imgPngPath)" style="width: 158px;height: 155px"/>
                </template>
              </el-table-column>
              <el-table-column label="数量" prop="imgNum" align="center"/>
              <el-table-column label="尺寸" prop="imgDimensions" align="center"/>
              <el-table-column label="材质" prop="fileMaterial" align="left">
                <template slot-scope="scope">
                  {{ echoImgMaterial(scope.row.imgMaterial) }}
                </template>
              </el-table-column>
            </el-table>
          </template>
        </el-table-column>
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="序号" align="center" width="50">
          <template v-slot="scope">
            {{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}
          </template>
        </el-table-column>
        <el-table-column label="编码" align="center" prop="id" width="240"/>
        <el-table-column label="店铺名称" align="center" prop="shopName" />
        <el-table-column label="链接地址" align="center" prop="link" show-overflow-tooltip/>
        <el-table-column label="商品ID" align="center" prop="productId" />
        <el-table-column label="印刷品" align="center" prop="printedMaterials" width="60">
          <template slot-scope="scope">
            <span v-if="scope.row.printedMaterials === 'Y'">是</span>
            <span v-else>否</span>
          </template>
        </el-table-column>
        <el-table-column label="状态" align="center" prop="prodStatus" width="55">
          <template v-slot="scope">
            <dict-tag :options="dict.type.sys_status" :value="scope.row.prodStatus"/>
          </template>
        </el-table-column>
        <el-table-column label="创建时间" align="center" prop="createTime" width="160"/>
        <el-table-column label="更新时间" align="center" prop="updateTime" width="160"/>
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button
              type="text"
              icon="el-icon-edit"
              @click="handleUpdate(scope.row)"
              v-hasPermi="['business:prodRel:edit']"
            >修改</el-button>
            <el-button
              type="text"
              :icon="scope.row.prodStatus === 'DELETED' ? 'el-icon-refresh-left' : 'el-icon-delete'"
              @click="handleChangeStatus(scope.row)"
              v-hasPermi="['business:storeMgmt:changeStatus']"
            >{{scope.row.prodStatus === 'DELETED' ? "恢复" : "删除" }}</el-button>
          </template>
        </el-table-column>
      </el-table>

      <pagination
        v-show="total>0"
        :pageRefs="this.$refs"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </div>

    <!-- 添加或修改商品关系对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="95%" append-to-body>
      <el-row>
        <el-form ref="form" :model="form" :rules="rules" label-width="80px">
          <el-col :span="24">
            <el-divider content-position="left">主要信息</el-divider>
          </el-col>
          <el-col :span="4">
            <el-form-item label="编码" prop="id">
              <el-input v-model="form.id" disabled placeholder="自动生成，无需填写" :style="form.id != null ? 'width: 160px;' : 'width: 240px;'"/>
              <el-button v-if="form.id != null" type="primary" v-clipboard:copy="form.id" v-clipboard:success="copySuccess" v-clipboard:error="copyFailed">复制</el-button>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="店铺" prop="shopId">
              <el-select v-model="form.shopId" @change="getShopList" filterable clearable placeholder="请选择店铺名称" style="width: 240px;">
                <el-option v-for="item in storeMgmtList" :key="item.id" :label="item.storeAbbr" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="链接" prop="link">
              <el-input v-model="form.link" placeholder="请输入链接地址" style="width: 240px;"/>
            </el-form-item>
          </el-col>
          <el-col :span="4" :push="1">
            <el-form-item label="商品ID" prop="productId">
              <el-input v-model="form.productId" placeholder="请输入商品id" style="width: 240px;"/>
            </el-form-item>
          </el-col>
          <el-col :span="4" :push="2">
            <el-form-item label="印刷品" prop="printedMaterials">
              <el-select v-model="form.printedMaterials" clearable placeholder="请选择是否印刷品" style="width: 240px;">
                <el-option
                  v-for="item in [{ label: '是', value: 'Y' }, { label: '否', value: 'N' }]"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-divider content-position="left">明细信息</el-divider>
            <el-table :data="tableData" height="400px" style="width: 100%">
              <el-table-column label="序号" align="center" prop="index" width="50">
                <template v-slot="scope">
                  {{ scope.$index + 1 }}
                </template>
              </el-table-column>
              <el-table-column label="素材编码" align="center" prop="imgId" />
              <el-table-column label="预览图" align="center">
                <template slot-scope="scope">
                  <image-preview :src="getImageUrl(scope.row.bucketUrl, scope.row.imgPngPath)" style="width: 100px;height: 100px;"/>
                </template>
              </el-table-column>
              <el-table-column label="数量" align="center">
                <template slot-scope="scope">
                  <span v-if="!scope.row.editShow">
                    {{ scope.row.imgNum }}
                  </span>
                  <el-input v-else placeholder="请输入数量" v-model="scope.row.imgNum" clearable />
                </template>
              </el-table-column>
              <el-table-column label="尺寸" align="center">
                <template slot-scope="scope">
                  <span v-if="!scope.row.editShow">
                    {{ scope.row.imgDimensions }}
                  </span>
                  <el-input v-else placeholder="请输入尺寸" v-model="scope.row.imgDimensions" clearable />
                </template>
              </el-table-column>
              <el-table-column label="材质" align="center">
                <template slot-scope="scope">
                  <span v-if="!scope.row.editShow">
                    {{ echoImgMaterial(scope.row.imgMaterial) }}
                  </span>
                  <el-select v-else v-model="scope.row.imgMaterial" filterable clearable placeholder="请选择材质" style="width: 200px;">
                    <el-option v-for="item in matMgmtList" :key="item.id" :label="item.matName" :value="item.id" />
                  </el-select>
                </template>
              </el-table-column>
              <el-table-column align="center" width="100">
                <template slot="header" slot-scope="scope">
                  <el-button icon="el-icon-connection" type="primary" @click="innerVisible = true"></el-button>
                </template>
                <template slot-scope="scope">
                  <el-button type="text" v-if="!scope.row.editShow" @click="getEditFileDate(scope.$index, true)">编辑</el-button>
                  <el-button type="text" v-if="!scope.row.editShow" @click="getUpdateFileDate(scope.$index,)">删除</el-button>
                  <el-button type="text" v-if="scope.row.editShow" @click="getEditFileDate(scope.$index, false, 'sure')" style="color: #85ce61;">确认</el-button>
                  <el-button type="text" v-if="scope.row.editShow" @click="getEditFileDate(scope.$index, false, 'cancel')" style="color: red;">取消</el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-col>
        </el-form>
      </el-row>

      <el-dialog width="30%" title="解析" :visible.sync="innerVisible" append-to-body>
        <el-input
          type="textarea"
          :rows="6"
          placeholder="请输入文件编码，多个文件编码用英文逗号隔开"
          v-model="fileIds">
        </el-input>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="handleAnalysis" :loading="selectFIleLoading">解 析</el-button>
          <el-button @click="innerVisible = false;fileIds = null">取 消</el-button>
        </div>
      </el-dialog>

      <div slot="footer" class="dialog-footer">
        <el-button type="danger" @click="reset">清空</el-button>
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 商品关系导入对话框 -->
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx"
        :headers="upload.headers"
        :action="upload.url + '?coverSupport=' + upload.coverSupport"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <div class="el-upload__tip" slot="tip">
            <el-checkbox v-model="upload.coverSupport" />校验商品ID重复
          </div>
          <span>仅允许导入xlsx格式文件。</span>
          <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="exportTemplate">下载模板</el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listProdRel,  getProdRel, addProdRel, updateProdRel, updateChangeStatus, getProdDetailsByMainId, refreshCache, delProdRel } from "@/api/business/prodrel";
import { getImgInfoByIds } from "@/api/business/imgInfo";
import { getNormalMatMgmtList } from "@/api/business/matMgmt"
import { getNormalStoreMgmtList } from "@/api/business/storeMgmt"
import {getToken} from "@/utils/auth";
import ResizeMixin from "@/layout/mixin/ResizeHandler";

export default {
  name: "ProdRel",
  mixins: [ResizeMixin],
  dicts: ['sys_status'],
  data() {
    return {
      // div高度
      divHeight: 0,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 商品关系表格数据
      prodRelList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        imgId: null,
        imgMaterial: null,
        shopId: null,
        shopName: null,
        link: null,
        productId: null,
        printedMaterials: null,
        prodStatus: null,
        add: null,
        userId: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        shopId: [
          { required: true, message: "店铺不能为空", trigger: "blur" }
        ],
        link: [
          { required: true, message: "链接地址不能为空", trigger: "blur" }
        ],
        productId: [
          { required: true, message: "商品id不能为空", trigger: "blur" }
        ],
        printedMaterials: [
          { required: true, message: "是否印刷品 Y是 N否不能为空", trigger: "blur" }
        ],
      },
      storeMgmtList: [],
      matMgmtList: [],
      detailsLoading: false, // 明细信息刷新时
      prodRelDetailsList: [], // 明细信息List
      oldTableData: {
        imgNum: null,
        imgDimensions: null,
        imgMaterial: null
      },
      tableData: [], // 明细信息表格数据
      innerVisible: false, // 解析素材ID
      selectFIleLoading: false, //解析按钮加载
      fileIds: "", //文件id
      // 是否为新增按钮
      isAdd: true,
      // 商品关系导入参数
      upload: {
        // 是否显示弹出层（商品关系导入）
        open: false,
        // 弹出层标题（商品关系导入）
        title: "商品关系导入",
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/business/prodRel/importTemplate",
        // 校验商品ID重复
        coverSupport: true,
      },
      fileList: [],
      // 上传时间
      dateRange: [],
    };
  },
  created() {
    this.getList();
    this.getNormalMatMgmtList();
    this.getNormalStoreMgmtList();
  },
  methods: {
    /** 展开行 */
    handleExpandChange(row, expandedRows){
      const _this = this
      if (expandedRows.length) {
        this.detailsLoading = true
        getProdDetailsByMainId(row.id).then(res => {
          this.detailsLoading = false
          row.children = res.rows;
          row.height = (res.rows.length*178+40) + 'px'
          this.$nextTick(() => {
            _this.$refs["divTable"].doLayout();
            if (_this.$refs["details"]) _this.$refs["details"].doLayout();
          })
        })
      }
    },
    /** 材质回显 */
    echoImgMaterial(id){
      const item = this.matMgmtList.find(item => item.id === id);
      return item ? item.matName : '';
    },
    /** 修改明细信息表格数据 */
    getEditFileDate(index, editShow, type){
      if (type === 'cancel'){
        this.tableData[index].imgNum = JSON.parse(JSON.stringify(this.oldTableData.imgNum));
        this.tableData[index].imgDimensions = JSON.parse(JSON.stringify(this.oldTableData.imgDimensions));
        this.tableData[index].imgMaterial = JSON.parse(JSON.stringify(this.oldTableData.imgMaterial))
        this.tableData[index].editShow = editShow
      }else {
        this.oldTableData = { ...this.tableData[index] }
        this.tableData[index].editShow = editShow
      }
    },
    /** 删除明细信息表格数据 */
    getUpdateFileDate(index){
      this.tableData.splice(index, 1)
    },
    /** 解析素材ID */
    handleAnalysis(){
      if (!this.fileIds){
        this.$modal.msgError("素材编码不能为空")
        return;
      }
      // 校验素材编码是否正确
      const pattern = /^([0-9a-zA-z]{26},)*[0-9a-zA-z]{26}(,[0-9a-zA-z]{26})*$/;
      if (!pattern.test(this.fileIds)) {
        this.$modal.msgError("素材编码字符串格式不正确")
        return;
      }

      this.getImgInfoByIds(this.fileIds);
      this.innerVisible = false;
      this.fileIds = null;

    },
    /** 根据素材编码查询文件信息 */
    getImgInfoByIds(ids){
      getImgInfoByIds(ids).then(res => {
        res.rows.map(item => {
          this.tableData.push({imgId: item.id, bucketUrl: item.bucketUrl, imgPngPath: item.imgPngPath, editShow: false})
        })
      })
    },
    /** 查询商品材质列表 */
    getNormalMatMgmtList(){
      getNormalMatMgmtList().then(res => {
        this.matMgmtList = res.data
      })
    },
    /** 查询店铺列表 */
    getNormalStoreMgmtList(){
      getNormalStoreMgmtList().then(res => {
        this.storeMgmtList = res.data
      })
    },
    /** 查询商品关系列表 */
    getList() {
      this.loading = true;
      listProdRel(this.$addDateRange(this.queryParams, this.dateRange)).then(response => {
        this.prodRelList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: this.isAdd === true ? null : this.form.id,
        shopId: null,
        shopName: null,
        link: null,
        productId: null,
        printedMaterials: null,
      };
      this.$resetForm("form");
      // 清空明细
      this.tableData = [];
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.$resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.isAdd = true;
      this.tableData = [];
      this.reset();
      this.open = true;
      this.title = "新增商品关系";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.isAdd = false;
      this.reset();
      const id = row.id || this.ids
      getProdRel(id).then(response => {
        this.form = response.data;
        getProdDetailsByMainId(id).then(res => {
          this.tableData = res.rows.map(item => {
            return { ...item, editShow: false };
          });
        })
        this.open = true;
        this.title = "修改商品关系";
      });
    },
    /** 店铺回显 */
    getShopList(value){
      const item = this.storeMgmtList.find(shop => shop.id === value);
      if (item) {
        this.form.shopName = item.storeAbbr
      }
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.form.prodRelDetailsList = this.tableData
          const judge = this.checkTableData(this.tableData)
          if (judge){
            if (this.form.id != null) {
              updateProdRel(this.form).then(response => {
                this.$modal.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              });
            } else {
              addProdRel(this.form).then(response => {
                this.form.id = response.data;
                this.$modal.msgSuccess("新增成功");
                this.getList();
              });
            }
          }
        }
      });
    },
    /** 判断是否有未填写的内容 */
    checkTableData(list) {
      if (!list.length) {
        this.$message.error("明细列表不能为空");
        return false;
      }
      let missingFields = []
      list.forEach((item, index) => {
        if (!item.imgMaterial) {
          missingFields.push(`第${index + 1}条的材质未填写;`);
        }
        if (!item.imgNum) {
          missingFields.push(`第${index + 1}条的数量未填写;`);
        } else if (item.imgNum.toString().length > 11) {
          missingFields.push(`第${index + 1}条的数量超过11位`);
        }
        if (!item.imgDimensions) {
          missingFields.push(`第${index + 1}条的尺寸未填写;`);
        }
      });
      // 如果有缺失的字段或无效的imgNum，则一次性提示
      if (missingFields.length > 0) {
        let message = '警告，以下数据存在问题：\n';
        if (missingFields.length > 0) {
          message += missingFields.join('\n');
        }

        this.$message.error(message);
        return false
      }else {
        return true
      }
    },
    /** 解锁或锁定按钮操作 */
    handleChangeStatus(row) {
      const ids = row.id || this.ids;
      let status = row.prodStatus === 'NORMAL'? '删除' : '恢复';
      this.$modal.confirm('是否确认' + status + '此数据项？').then(function() {
        row.prodStatus = row.prodStatus === 'NORMAL'? 'DELETED' : 'NORMAL';
        return updateChangeStatus({ ids: ids, status: row.prodStatus })
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess(status + "成功");
      }).catch(() => {});
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('注意：此删除不可恢复，是否确认删除？').then(function() {
        return delProdRel(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 复制成功 */
    copySuccess(){
      this.$modal.msgSuccess("复制成功")
    },
    /** 复制失败 */
    copyFailed(){
      this.$modal.msgError("复制失败")
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.open = true;
    },
    /** 下载商品关系模板 */
    exportTemplate(){
      this.$download.common('/business/prodRel/exportTemplate', {
      }, `商品关系模板_${new Date().getTime()}.xlsx`)
    },
    /** 文件上传中处理 */
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    /** 文件上传成功处理 */
    handleFileSuccess(response, file, fileList) {
      const message = response.code === 200
        ? '导入成功，请到下载中心查看'
        : `导入失败：${response.msg || '未知错误'}`;
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert(`<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>${message}</div>`, "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    /** 导入确定按钮 */
    submitFileForm(){
      this.$refs.upload.submit()
    },
    /** 刷新缓存 */
    handleRefreshCache(){
      refreshCache().then(() => {
        this.$modal.msgSuccess("刷新成功");
      });
    },
    /** 生成图片 URL 并添加时间戳 */
    getImageUrl(bucketUrl, imgPngPath) {
      const timestamp = new Date().getTime();
      return `${bucketUrl}${imgPngPath}?t=${timestamp}`;
    },
  }
};
</script>
